package com.mybatisLike.sqlSession;

import java.lang.reflect.Proxy;

/**
 * @author isam2016
 * @create 2021-08-23 5:59 PM
 */
public class MySqlsession {
    // 执行器
    private Excutor excutor = new MyExcutor();

    private MyConfiguration myConfiguration = new MyConfiguration();

    public <T> T selectOne(String statement, Object parameter){
        return excutor.query(statement, parameter);
    }
    @SuppressWarnings("unchecked")
    public <T> T getMapper(Class<T> tClass){
        // 动态代理
        return (T) Proxy.newProxyInstance(
                tClass.getClassLoader(),
                new Class[]{tClass},
                new MyMapperProxy(myConfiguration, this));
    }
}
